package com.gxa.employment.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.employment.entity.dto.PageBean;
import com.gxa.employment.entity.pojo.Interview;
import com.gxa.employment.entity.vo.PageVo;
import com.gxa.employment.mapper.InterviewMapper;
import com.gxa.employment.service.InterviewService;

import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 模拟面试记录表 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-03-25
 */
@Transactional(rollbackFor = Throwable.class)
@Service
public class InterviewServiceImpl extends ServiceImpl<InterviewMapper, Interview> implements InterviewService {


    private InterviewMapper interviewMapper;

    public InterviewServiceImpl(InterviewMapper interviewMapper) {
        this.interviewMapper = interviewMapper;
    }
    //    添加模拟面试的结果
    @Transactional(rollbackFor = Throwable.class)
    @Override
    public Boolean add(Interview interview) {
        return this.save(interview);
    }

    //查
    @Override
    public PageVo<Interview> select(PageBean pageBean) {
        System.out.println(pageBean);
//        分页查询
        IPage<Interview> page = new Page<>(pageBean.getPage(), pageBean.getSize());
        QueryWrapper<Interview> queryWrapper = new QueryWrapper<>(Interview.class);
        page(page,queryWrapper);
        long total = page.getTotal();
        List<Interview> records = page.getRecords();
        return new PageVo<>(total,records);
    }
}
